<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <style>
      body {
        display: flex;
        height: 100vh;
        align-items: center;
        justify-content: center;
      }
      input {
        width: 180px;
        height: 30px;
      }
      .btn {
        width: 130px;
        height: 40px;
      }
    </style>
    <script src="../jquery-3.6.3-min.js"></script>
  </head>
  <body>
    <div>
      <form action="#" onsubmit="return sub()">
        <label for="account_number">账号:</label>
        <input
          type="text"
          name="account_number"
          id="account_number"
          value="阿巴阿巴"
        />
        <!-- 该submit按钮只是位form服务的功能,本身没有提交事件,只有form有 -->
        <input class="btn" type="submit" value="提交" />
      </form>
      <p id="txt"></p>
    </div>
    <script>
      function sub() {
        // var txt = document.getElementById("account_number");
        if ($("#account_number").val() == "") {
          $("#txt").html("输入不能为空!").css({
            color: "red",
            "text-shadow": " 0 0 3px red",
          });

          return false;
        }
        return true;
      }
    </script>
  </body>
</html>
